home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0195.lzh / AMOSLIST / text0207.txt < prev    next >
Encoding:
Text File  |  1995-02-01  |  3.3 KB  |  104 lines

  1. Forwarded message:
  2. > From naimoli@cli.di.unipi.it Mon Jan 23 08:38:18 1995
  3. > From: naimoli@cli.di.unipi.it
  4. > Message-Id: <9501230738.AA07312@helen.cli.di.unipi.it>
  5. > Subject: no subject (file transmission)
  6. > To: naimoli@cli.di.unipi.it
  7. > Date: Mon, 23 Jan 1995 08:38:16 +0100 (MET)
  8. > X-Mailer: ELM [version 2.4 PL22]
  9. > Mime-Version: 1.0
  10. > Content-Type: text/plain; charset=US-ASCII
  11. > Content-Transfer-Encoding: 7bit
  12. > Content-Length: 1789      
  13.  
  14. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  15.  
  16.  Ive already given an answer to this, but was for urgent problems, as it worked only if the ellipse was drawn in a unique colour (different from any in the background).
  17.  
  18.  The following example shows how to achieve the effect and can be extended to any kind of shapes (not just ellipse, but it's easier with regular shapes).
  19.  
  20.  You'll find a procedure inside the example, called OUTELLIPSE that isn't called. It's sufficient to copy that and it'll work. In the example I follow a different way, just to reduce the waste of memory, but the procedure is easier n more safe. 
  21.  
  22.  
  23.  
  24. > 'Outside-Clear by Andy Naimoli 
  25. > 'Example for clearing anything outside an ellipse
  26. > Flash Off : Curs Off 
  27. > FLAG=False : Rem switch to true for fast-mode 
  28. > SW=320 : SH=200
  29. > CX=160 : CY=100 : R1=80 : R2=40
  30. > For N=1 To 100
  31. >  Ink Rnd(31) : Draw To Rnd(SW),Rnd(SH)
  32. > Next N
  33. > PAUSA["Now draw ellipse.",FLAG]
  34. > Ellipse CX,CY,R1,R2
  35. > PAUSA["Done! Make a copy.",FLAG]
  36. > If FLAG Then Auto View Off 
  37. > Screen Open 1,R1*2,R2*2,32,Lowres : Flash Off 
  38. > If FLAG Then Screen Hide 1
  39. > Screen Copy 0,CX-R1,CY-R2,CX+R1,CY+R2 To 1,0,0
  40. > PAUSA["Delete inside.",FLAG]
  41. > Ink 0
  42. > For R=Min(R1,R2) To 1 Step -1 : Bell 90-R
  43. >  If R1<R2 Then Ellipse R1,R2,R,R2 Else Ellipse R1,R2,R1,R
  44. > Next R
  45. > If R1<R2 Then Draw R1,0 To R1,Screen Height Else Draw 0,R2 To Screen Width,R2
  46. > PAUSA["Xor with original",FLAG]
  47. > Screen Copy 1,0,0,Screen Width,Screen Height To 0,CX-R1,CY-R2,96
  48. > Screen Close 1
  49. > If FLAG Then Auto View On 
  50. > PAUSA["Clear all around",FLAG]
  51. > Cls ,0,0 To SW,CY-R2
  52. > Cls ,0,CY+R2 To SW,SH
  53. > Cls ,0,CY-R2 To CX-R1,CY+R2
  54. > Cls ,CX+R1,CY-R2 To SW,CY+R2
  55. > Procedure PAUSA[T$,F]
  56. > If F Then Pop Proc
  57. > S=Screen : Screen 0 : Locate ,24 : Cline : Centre T$ : Screen S
  58. > Bell : Wait Key 
  59. > End Proc
  60. > Procedure OUTELLIPSE[CX,CY,R1,R2]
  61. > Rem This example uses Screen 0 as source and Screen 1 as target
  62. > Rem considering that source is the default screen
  63. > Rem Open a screen like the source one
  64. > Auto View Off
  65. > Screen Open 1,320,200,32,Lowres
  66. > Screen Hide 1
  67. > Rem Copy source to target and draw a filled ellipse (Ink 0)
  68. > Screen Copy 0 To 1
  69. > Screen 1 : Ink 0 : Ellipse CX,CY,R1,R2
  70. > For R=Min(R1,R2) To 1 Step -1
  71. >  If R1<R2 Then Ellipse CX,CY,R,R2 Else Ellipse CX,CY,R1,R
  72. > Next R
  73. > If R1<R2 Then Draw R1,0 To R1,Screen Height Else Draw 0,R2 To Screen Width,R2
  74. > Rem Transfer target on source XORing to preserve graphic inside ellipse!
  75. > Screen Copy 1 To 0,,,96 : Screen Close 1
  76. > End Proc
  77.  
  78.  The idea is simple (but not so easy to be thought): just create a copy of the screen n then fill IN the shape created. Then transfer this on the original background XORing it all, so only the area inside the shape is preserved!!!!!
  79.  
  80.  
  81.  
  82.         Andy - naimoli@cli.di.unipi.it
  83.  
  84.      * *** *  * * 
  85.     ** * * **  *             May the power be with us!!!!!!!!!!!!!!
  86.    *** * * *** *
  87.  
  88.